from enum import Enum


class Gender(Enum):
    MALE = 1
    FEMALE = 2


print(Gender.MALE)
print(type(Gender.MALE))  # <enum 'Gender'>

print(Gender.MALE.name)  # MALE
print(Gender.MALE.value)  # 1

# 知道了name，需要转换为枚举
name = "MALE"
n = Gender[name]
print(n)
print(n.name)

# 知道了value，转化为枚举
value = 2
v = Gender(2)
print(v)
print(v.name, v.value)

# 循环
for g in Gender:
    print(g.name)


# 枚举继承
# 父类必须没有定义过成员
class Type(Enum):
    pass


class MyType(Type):
    HAND = 2


